import {Directive,DirectiveBinding} from 'vue'

export const loadmore:Directive = {
    mounted(el:HTMLElement,binding:DirectiveBinding){
        console.log("元素",el)
        console.log("binding",binding)
        const selectDom = document.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
        
        selectDom?.addEventListener("scroll",function(e:Event){
            const isEnd = Math.floor((e.target as HTMLElement).scrollHeight) - Math.ceil((e.target as HTMLElement).scrollTop) <= Math.floor((e.target as HTMLElement).clientHeight)
            if(isEnd){
                binding.value()
            }
        })
    }
}